import { WEBSOCKETS, toSuccess } from "@sker/core";
import { useData } from "@sker/runtime";
import { container } from "tsyringe";
import { z } from "zod";


function uploadFileFromLocal() {
    const input = z.object({
        path: z.string(),
    });
    const body = input.parse(useData())
    const sockets = container.resolve(WEBSOCKETS)
    sockets.forEach(socket => {
        socket.send(JSON.stringify({ type: 'UPLOAD_FILE_FROM_LOCAL', payload: { path: body.path } }))
    })
    return toSuccess(true)
}
export default uploadFileFromLocal;
